package adminLog

import (
	"grpc.getaway.adminspro.padmins.com/internal/api/module/admin/container"
	"grpc.getaway.adminspro.padmins.com/internal/api/utils/rpc"
	"grpc.getaway.adminspro.padmins.com/pkg/businessCommonQuery"
	pbAdmin "grpc.getaway.adminspro.padmins.com/pkg/proto/admin"
	"strconv"
)

func Index(c *container.Context) (interface{}, error) {
	BusinessCommonQuery, e := businessCommonQuery.BuildByRequest(c.Request)
	if e != nil {
		return nil, e
	}

	onlyAuth, _ := strconv.Atoi(c.Request.ParamsToString("only_auth"))

	req := &pbAdmin.AdminOperationLogIndexReq{
		BusinessCommonQuery: BusinessCommonQuery,
		ShowTotal:           true,
		OperaterId:          c.Auth.Data.Admin.Id,
		OnlyAuth:            int32(onlyAuth),
	}

	return rpc.GetAdminClient().AdminOperationLogIndex(c.GetContext(), req)
}
